/*
* BlowerCalculatorService.java
* Created on  2015/8/5 14:46
* 版本       修改时间          作者      修改内容
* V1.0.1    2015/8/5       xfz    初始版本
*
*/

package com.infitecs.eyas.blower.service;

import com.infitecs.eyas.blower.dao.BlowerBaseCalDao;
import com.infitecs.eyas.blower.dao.BlowerCalculatorDao;
import com.infitecs.eyas.blower.model.BlowerBaseCal;
import com.infitecs.eyas.blower.model.BlowerCalculator;
import com.infitecs.eyas.session.SessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 类的描述信息
 *
 * @author xfz
 * @version 1.0.1
 */
@Service
public class BlowerCalculatorService {

    @Autowired
    private SessionService sessionService;

    @Autowired
    private BlowerCalculatorDao blowerCalculatorDao;

    @Autowired
    private BlowerBaseCalDao blowerBaseCalDao;

    public void insertBlowerCalculator() {
        int caseId = sessionService.getCaseId();
        BlowerCalculator blowerCalculator = new BlowerCalculator();
        blowerCalculator.setCaseId(caseId);
        blowerCalculator.setClassA("btn green addable");
        blowerCalculator.setClassI("fa fa-plus");
        for (int i = 1; i <= 7; i++) {
            blowerCalculator.setLagreType(1);
            switch (i) {
                case 1:
                    blowerCalculator.setSmallType(i);
                    blowerCalculator.setTitle("管段1");
                    blowerCalculatorDao.insertBlowerCalculator(blowerCalculator);
                    break;
                case 2:
                    blowerCalculator.setSmallType(i);
                    blowerCalculator.setTitle("零件1");
                    blowerCalculatorDao.insertBlowerCalculator(blowerCalculator);
                    break;
                case 3:
                    blowerCalculator.setSmallType(i);
                    blowerCalculator.setTitle("部件1");
                    blowerCalculatorDao.insertBlowerCalculator(blowerCalculator);
                    break;
                case 4:
                    blowerCalculator.setSmallType(i);
                    blowerCalculator.setTitle("设备1");
                    blowerCalculatorDao.insertBlowerCalculator(blowerCalculator);
                    break;
                case 5:
                    blowerCalculator.setSmallType(i);
                    blowerCalculator.setTitle("提升压头损失");
                    blowerCalculatorDao.insertBlowerCalculator(blowerCalculator);
                    break;
                case 6:
                    blowerCalculator.setSmallType(i);
                    blowerCalculator.setTitle("加速损失");
                    blowerCalculatorDao.insertBlowerCalculator(blowerCalculator);
                    break;
                case 7:
                    blowerCalculator.setSmallType(i);
                    blowerCalculator.setTitle("自生通风");
                    blowerCalculatorDao.insertBlowerCalculator(blowerCalculator);
                    break;

            }
        }

        for (int i = 1; i <= 7; i++) {
            blowerCalculator.setLagreType(2);
            switch (i) {
                case 1:
                    blowerCalculator.setSmallType(i);
                    blowerCalculator.setTitle("管段1");
                    blowerCalculatorDao.insertBlowerCalculator(blowerCalculator);
                    break;
                case 2:
                    blowerCalculator.setSmallType(i);
                    blowerCalculator.setTitle("零件1");
                    blowerCalculatorDao.insertBlowerCalculator(blowerCalculator);
                    break;
                case 3:
                    blowerCalculator.setSmallType(i);
                    blowerCalculator.setTitle("部件1");
                    blowerCalculatorDao.insertBlowerCalculator(blowerCalculator);
                    break;
                case 4:
                    blowerCalculator.setSmallType(i);
                    blowerCalculator.setTitle("设备1");
                    blowerCalculatorDao.insertBlowerCalculator(blowerCalculator);
                    break;
                case 5:
                    blowerCalculator.setSmallType(i);
                    blowerCalculator.setTitle("提升压头损失");
                    blowerCalculatorDao.insertBlowerCalculator(blowerCalculator);
                    break;
                case 6:
                    blowerCalculator.setSmallType(i);
                    blowerCalculator.setTitle("加速损失");
                    blowerCalculatorDao.insertBlowerCalculator(blowerCalculator);
                    break;
                case 7:
                    blowerCalculator.setSmallType(i);
                    blowerCalculator.setTitle("自生通风");
                    blowerCalculatorDao.insertBlowerCalculator(blowerCalculator);
                    break;
            }
        }
    }

    public List<BlowerCalculator> getBlowerCalculatorList() {
        return blowerCalculatorDao.getBlowerCalculator(sessionService.getCaseId());
    }

    public List<BlowerCalculator> getIn() {
        return blowerCalculatorDao.getIn(sessionService.getCaseId());
    }

    public List<BlowerCalculator> getOut() {
        return blowerCalculatorDao.getOut(sessionService.getCaseId());
    }

    public int insertBlower(BlowerCalculator blowerCalculator) {
        blowerCalculator.setCaseId(sessionService.getCaseId());
        blowerCalculatorDao.insertBlowerCalculator(blowerCalculator);
        return blowerCalculator.getId();
    }

    public void del(int id) {
        blowerCalculatorDao.del(id);
    }

    public void editTitle(BlowerCalculator blowerCalculator) {
        blowerCalculatorDao.editTitle(blowerCalculator);
    }

    public void update(BlowerCalculator blowerCalculator) {
        blowerCalculatorDao.update(blowerCalculator);
    }

    public BlowerBaseCal getBlowerBaseCal(){
        return blowerBaseCalDao.getBlowerBaseCal(sessionService.getCaseId());
    }

    public void insertNewOnceFanBase() {
        blowerBaseCalDao.insertNewBaseCal(sessionService.getCaseId());
    }

    public void updateParam(BlowerBaseCal blowerBaseCal) {
        blowerBaseCalDao.updateParam(blowerBaseCal);
    }
}
